{% load i18n admin_urls admin_static admin_modify material_form material_form_internal %}
<div class="row">
    <div class="formset-field col s12" data-formset-prefix="{{ element.inline.formset.prefix }}">
        {% part element.inline label %}<h5>{{ element.inline.opts.verbose_name_plural|capfirst }}</h5>{% endpart %}

        {% if element.inline.formset.non_form_errors %}
        <div>
            <small class="errornote">{{ element.inline.formset.non_form_errors }}</small>
        </div>
        {% endif %}

        <table class="table responsive-table">
            <tbody data-formset-body>
                {% for inline_admin_form in element.inline %}
                {% if inline_admin_form.form.prefix ==  element.inline.formset.empty_form.prefix %}<script type="form-template" data-formset-empty-form>{% endif %}

                <tr data-formset-form>
                    {% part inline_admin_form.form hidden %}
                        {% if inline_admin_form.needs_explicit_pk_field %}{{ inline_admin_form.pk_field.field }}{% endif %}
                        {{ inline_admin_form.fk_field.field }}
                        {% for fieldset in inline_admin_form %}{% for line in fieldset %}{% for field in line %}
                            {% if field.field.is_hidden %} {{ field.field }} {% endif %}
                        {% endfor %}{% endfor %}{% endfor %}
                    {% endpart %}

                    {% part inline_admin_form.form visible %}
                        {% for fieldset in inline_admin_form %}{% for line in fieldset %}{% for field in line %}
                            {% if not field.field.is_hidden %}
                            <td{% if field.field.name %} class="field-{{ field.field.name }}"{% endif %}>
                                {% if field.is_readonly %}
                                <div class="row">
                                    {% if 'admin/img/icon-' in field.contents %}
                                        <div class="input-field col s12">
                                            <input type="checkbox" id="test7" {% if 'icon-yes' in field.contents %}checked="checked"{% endif %} disabled="disabled" />
                                            <label for="test7">{{ field.field.label|title }}</label>
                                        </div>
                                    {% else %}
                                        {% if '<' in field.contents and '>' in field.contents or field.contents == "" %}
                                            {{field.contents}}
                                        {% else %}
                                            <div class="input-field col s12">
                                                <label class="active">{{ field.field.label|title }}</label>
                                                <input disabled value="{{ field.contents }}">
                                            </div>
                                        {% endif %}
                                   {% endif %}
                                </div>
                                {% else %}
                                    {% with form=inline_admin_form.form %}{% render field.field %}{% endrender %}{% endwith %}
                                {% endif %}
                            </td>
                            {% endif %}
                        {% endfor %}{% endfor %}{% endfor %}
                    {% endpart %}

                    {% if element.inline.formset.can_delete %}
                    <td style="vertical-align:middle;width:60px">
                        <div style="display:none">{{ inline_admin_form.deletion_field.field }}</div>
                        <button type="button" class="btn btn-flat white lighten-4" style="padding:0px 10px;font-size:0.7rem;height:calc(100% - 15px);width:100%" data-formset-delete-button><i class="material-icons">clear</i></button>
                    </td>
                    {% endif %}
                </tr>

                {% if inline_admin_form.form.prefix ==  element.inline.formset.empty_form.prefix %}</script>{% endif %}

                {% endfor %}
            </tbody>
        </table>
        {% if element.inline.formset.max_num != 0 %}
        <button type="button" class="btn btn-flat grey lighten-4" style="padding:0px 40px;width:100%" data-formset-add><i class="material-icons">add</i></button>
        {% endif %}
        {{ element.inline.formset.management_form }}
    </div>
</div>
